package com.blog.utils;

/**
 * Copyright (C), 2022
 * Author: 苏大大
 * Date: 2022-04-19 17:12
 * FileName: UUIDUtils
 * Description:
 */
public class UUIDUtils {

    /**
     * 随机生成字符，只有数字
     * @param
     */
    public static Long getNumber() {
        String uuid = "";
        for (Integer i = 0; i < 15; i++) {
            String randChar = String.valueOf(Math.round(Math.random() * 9));
            uuid = uuid.concat(randChar);
        }
        Long uid=Long.parseLong(uuid);
        return uid;
    }

    public static String create(Integer length) {
        String uid = "";
        for (Integer i = 0; i < length; i++) {
            int index = (int) Math.round(Math.random() * 2);
            String randChar = "";
            switch (index) {
                case 0:
                    //大写字符
                    randChar = String.valueOf((char) Math.round(Math.random() * 25 + 65));
                    break;
                case 1:
                    //小写字符
                    randChar = String.valueOf((char) Math.round(Math.random() * 25 + 97));
                    break;
                default:
                    //数字
                    randChar = String.valueOf(Math.round(Math.random() * 9));
                    break;
            }
            uid = uid.concat(randChar);
        }
        return uid;
    }

    public static void main(String[] args) {
        for (int i=0;i<=8;i++){
            System.out.println(create(16));
        }

    }
}
